using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace LogikBug
{
// ReSharper disable InconsistentNaming
	/// <summary>
	/// 
	/// </summary>
	public static class IEnumerableExtensions
// ReSharper restore InconsistentNaming
	{
		/// <summary>
		/// 
		/// </summary>
		/// <param name="enumerable"></param>
		/// <typeparam name="T"></typeparam>
		/// <returns></returns>
		public static bool HasElements<T>(this IEnumerable<T> enumerable)
		{
			return ((IEnumerable)enumerable).HasElements();
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="enumerable"></param>
		/// <returns></returns>
		public static bool HasElements(this IEnumerable enumerable)
		{
			if (enumerable != null)
			{
				foreach (var item in enumerable)
				{
					return true;
				}
			}

			return false;
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="enumerable"></param>
		/// <typeparam name="T"></typeparam>
		/// <returns></returns>
		public static IList<T> ToList<T>(this IEnumerable enumerable)
		{
			return new List<T>(enumerable.OfType<T>());
		}
	}
}